<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<%@page import="java.util.*, java.sql.*" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Where You From?</title>
</head>
<body>

<% 

	Class.forName("org.postgresql.Driver");
	Connection connect = DriverManager.getConnection("jdbc:postgresql://localhost/tester?user=postgres&password=admin");

	Object vec = session.getAttribute("degreeInfoSes");
	if(vec != null)
	{
		session.removeAttribute("degreeInfoSes");
	}
	String firstNameParam = request.getParameter("firstName");
	String middleInitialParam = request.getParameter("middleInitial");
	String lastNameParam = request.getParameter("lastName");
	
	
	session.setAttribute( "firstNameSes", firstNameParam);
	session.setAttribute( "middleInitialSes", middleInitialParam);
	session.setAttribute( "lastNameSes", lastNameParam);

	
	%>
	<%= session.getAttribute("firstNameSes") %>
	<%= session.getAttribute("middleInitialSes") %>
	<%= session.getAttribute("lastNameSes") %>
	<br>
	<br>
	In which county do you hold your primary citizenship?<br><br>
  	
	<%
	String path1 = config.getServletContext().getRealPath("countries.txt");
	
	PreparedStatement prepStmt;
	ResultSet rset;
	prepStmt = connect.prepareStatement("SELECT * FROM countries");
	rset = prepStmt.executeQuery();
	Vector countries = new Vector();
	Vector countryID = new Vector();
	while(rset.next())
	{
		countryID.add(rset.getString("id"));
		countries.add(rset.getString("country"));
	}
	
	%>

	<div id="left_wrapper">
	<div id="left">
	<p>
	
	<%
	for(int i=0; i<countries.size()/3; i++)
	{%>
		<a href="3_Resident.jsp?citizenID=<%= countryID.get(i) %>&citizen=<%= countries.get(i) %>" > <%= countries.get(i) %></a><br>
		

	<%}%>
	
	</p>
	</div>
	</div>
	
	<div id="middle_wrapper">
	<div id="left">
	<p>
	
	<%
	for(int i=countries.size()/3; i< 2 * (countries.size()/3); i++)
	{%>
		<a href="3_Resident.jsp?citizenID=<%= countryID.get(i) %>&citizen=<%= countries.get(i) %>" > <%= countries.get(i) %></a><br>
		

	<%} %>
	
	</p>
	</div>
	</div>
	
	<div id="right_wrapper"> 
	<div id="right">
	<p>
	
	<%
	for(int i= 2 * (countries.size()/3); i< countries.size(); i++)
	{%>
		<a href="3_Resident.jsp?citizenID=<%= countryID.get(i) %>&citizen=<%= countries.get(i) %>" > <%= countries.get(i) %></a><br>
		

	<%} %>
	
	</p>
	</div>
	</div>


	


<br><br>

	</body>
</html>